# -*- coding:utf-8 -*-
import MySQLdb

class Singleton(object):
    def __new__(cls,*args,**kw):
        if not hasattr(cls,"_instance"):
            orig = super(Singleton,cls)
            cls._instance = orig.__new__(cls,*args,**kw)
        return cls._instance  

class mysqlDao(Singleton):
    def __init__(self):
        self.__db_host     = '127.0.0.1'
        self.__db_port     = 3306
        self.__db_user     = 'aizhimiyu'
        self.__db_pass     = 'ml0604'
        self.__db_database = 'aiyu'
        self.__db_conn     = MySQLdb.connect(\
                host   = self.__db_host,\
                port   = self.__db_port,\
                user   = self.__db_user,\
                passwd = self.__db_pass)
        self.__db_conn.autocommit(True)
        self.__db_conn.select_db(self.__db_database)
    def getInstance(self):
        return self.__db_conn
